<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import = "java.util.*" %>
<%@ page import = "com.sinodata.bsm.common.vo.Probe" %>
<%@ include file="../include/taglib.jsp"%>

<%
    response.setHeader("Cache-Control", "no-store");
	response.setHeader("Pragrma", "no-cache");
	response.setDateHeader("Expires", 0);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Telnet测试页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<%@ include file="../include/common.jsp"%>

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/sub_menu.css" />

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/selfmainten/tool.css" />
	
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jsframework.js"></script>

	
<script type=text/javascript>
	function docmd(){
		var probe = $('#probeId option:selected').val();
		
		var isChecked = $('#pool').is(':checked');
		 $.ajax({
			   type: "POST", 
			   url: '${pageContext.request.contextPath}/selfmainten/tool!execTelnet.action', //请求的action
			   data: {
				   probeid:probe,
				   ip :$('#ip').val(),
				   port:$('#port').val(),
				   user :$('#user').val(),
				   pwd :$('#pwd').val(),
				   pool:isChecked,
				   cmd :$('#cmd').val(),
				   prompt:$('#prompt').val()
			   },
			   dataType: 'json',
			   success: function(data){ //结果
				   $('#result').val(data.result);
			   }
		});
	}
	
	$(function() {
		$('#cmd').bind('keydown', function(event){
			   if (event.keyCode=="13"){
				   docmd();
				   return false;
			   }
		});
		$("#probeId").msDropDown().data("dd");
	});
</script>
</head>
<body >
	<div class="searchFormStyle search" >
		 <span class="search-span">
  		    <label>采集器：</label>
  		    <select id="probeId" name = "probeId"  class = "select search-input"  >
	    					 <option value="" title=''>---- 请选择采集器 ----</option>
	    					<%
	    						List<Probe> probes = (List<Probe>)request.getAttribute("probeList");
	    						if(probes!=null)
	    						for(Probe  p : probes){
	    						    if(p.getStatus()==3){
	  	    			    				out.println("<option value='"+p.getId()+"' title='/bsm/style/default/bsm/images/proberun.png' >已启_"+p.getId()+"_"+p.getName()+"</option>");
	  	    						    }else{
	  	  	    			    			out.println("<option value='"+p.getId()+"' title='/bsm/style/default/bsm/images/probestop.png' >未启_"+p.getId()+"_"+p.getName()+"</option>");
	  	    						    }
	    						}
	    					%>
	    	</select>
    	 </span>
    	<span class="search-span">
  		    <label >命令提示符：</label>
  			<input type="text" id="prompt" name="prompt" class="search-input" value="#">
    	</span>
	</div>
	
	<div class="searchFormStyle search" >
		<span class="search-span">
  		    <label >URL地址：</label>
  			<input type="text" id="ip" name="ip" class="search-input-ip" value="10.200.200.1">
  		    <label>:</label>
  			<input type="text" id="port" name="port" class="search-input-pwd" value="23" >
    	</span>
    	
   		<span class="search-span">
   		   <input type='checkbox' value="1" name="pool" id="pool" "/>
		   <label for="pool" tabindex="1"><font color=#0000ff>使用连接池</font></label>
	    </span>
	</div>
	
	<div class="searchFormStyle search" >
		<span class="search-span">
  		    <label >用户名：</label>
  			<input type="text" id="user" name="user" class="search-input" value="bsm">
    	</span>
    	<span class="search-span">
   		    <label >密码：</label>
  			<input type="text" id="pwd" name="pwd"  style="width:300px;" value="bsm123">
	    </span>
	</div>
	
	<div class="searchFormStyle search" >
		<span class="search-span-cmd">
	 		<textarea style="width:800px;height:32px;"  id="cmd" name="cmd"></textarea>
	 	</span>
	 	<span class="search-span-cmd">
	 		<input type="button" value="执行命令" class="btn-4 btn-h" onclick="docmd();">
	    </span>
	</div>
	
	<div class="searchFormStyle search" >
		<textarea style="width: 900px;height: 350px;" id="result" name="result"></textarea>
	</div>
</body>
</html>